package com.das.mechanic_base.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.das.mechanic_base.widget.StringConverter;
import com.das.mechanic_base.widget.X3IntegerConverter;
import java.util.List;

import com.das.mechanic_base.bean.siveprocess.SiveProBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "SIVE_PRO_BEAN".
*/
public class SiveProBeanDao extends AbstractDao<SiveProBean, Long> {

    public static final String TABLENAME = "SIVE_PRO_BEAN";

    /**
     * Properties of entity SiveProBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Index = new Property(1, Long.class, "index", false, "INDEX");
        public final static Property List = new Property(2, String.class, "list", false, "LIST");
        public final static Property Name = new Property(3, String.class, "name", false, "NAME");
        public final static Property Sn = new Property(4, String.class, "sn", false, "SN");
        public final static Property ResourceIdList = new Property(5, String.class, "resourceIdList", false, "RESOURCE_ID_LIST");
        public final static Property StandardOrNot = new Property(6, boolean.class, "standardOrNot", false, "STANDARD_OR_NOT");
        public final static Property ProductCategoryNameList = new Property(7, String.class, "productCategoryNameList", false, "PRODUCT_CATEGORY_NAME_LIST");
        public final static Property ExampleImgUrl = new Property(8, String.class, "exampleImgUrl", false, "EXAMPLE_IMG_URL");
        public final static Property Description = new Property(9, String.class, "description", false, "DESCRIPTION");
        public final static Property TechnicsSn = new Property(10, String.class, "technicsSn", false, "TECHNICS_SN");
        public final static Property ServiceBaseSn = new Property(11, String.class, "serviceBaseSn", false, "SERVICE_BASE_SN");
        public final static Property NeedPhoto = new Property(12, boolean.class, "needPhoto", false, "NEED_PHOTO");
    }

    private final StringConverter listConverter = new StringConverter();
    private final X3IntegerConverter resourceIdListConverter = new X3IntegerConverter();
    private final StringConverter productCategoryNameListConverter = new StringConverter();

    public SiveProBeanDao(DaoConfig config) {
        super(config);
    }
    
    public SiveProBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"SIVE_PRO_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"INDEX\" INTEGER," + // 1: index
                "\"LIST\" TEXT," + // 2: list
                "\"NAME\" TEXT," + // 3: name
                "\"SN\" TEXT," + // 4: sn
                "\"RESOURCE_ID_LIST\" TEXT," + // 5: resourceIdList
                "\"STANDARD_OR_NOT\" INTEGER NOT NULL ," + // 6: standardOrNot
                "\"PRODUCT_CATEGORY_NAME_LIST\" TEXT," + // 7: productCategoryNameList
                "\"EXAMPLE_IMG_URL\" TEXT," + // 8: exampleImgUrl
                "\"DESCRIPTION\" TEXT," + // 9: description
                "\"TECHNICS_SN\" TEXT," + // 10: technicsSn
                "\"SERVICE_BASE_SN\" TEXT," + // 11: serviceBaseSn
                "\"NEED_PHOTO\" INTEGER NOT NULL );"); // 12: needPhoto
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SIVE_PRO_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, SiveProBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long index = entity.getIndex();
        if (index != null) {
            stmt.bindLong(2, index);
        }
 
        List list = entity.getList();
        if (list != null) {
            stmt.bindString(3, listConverter.convertToDatabaseValue(list));
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(4, name);
        }
 
        String sn = entity.getSn();
        if (sn != null) {
            stmt.bindString(5, sn);
        }
 
        List resourceIdList = entity.getResourceIdList();
        if (resourceIdList != null) {
            stmt.bindString(6, resourceIdListConverter.convertToDatabaseValue(resourceIdList));
        }
        stmt.bindLong(7, entity.getStandardOrNot() ? 1L: 0L);
 
        List productCategoryNameList = entity.getProductCategoryNameList();
        if (productCategoryNameList != null) {
            stmt.bindString(8, productCategoryNameListConverter.convertToDatabaseValue(productCategoryNameList));
        }
 
        String exampleImgUrl = entity.getExampleImgUrl();
        if (exampleImgUrl != null) {
            stmt.bindString(9, exampleImgUrl);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(10, description);
        }
 
        String technicsSn = entity.getTechnicsSn();
        if (technicsSn != null) {
            stmt.bindString(11, technicsSn);
        }
 
        String serviceBaseSn = entity.getServiceBaseSn();
        if (serviceBaseSn != null) {
            stmt.bindString(12, serviceBaseSn);
        }
        stmt.bindLong(13, entity.getNeedPhoto() ? 1L: 0L);
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SiveProBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long index = entity.getIndex();
        if (index != null) {
            stmt.bindLong(2, index);
        }
 
        List list = entity.getList();
        if (list != null) {
            stmt.bindString(3, listConverter.convertToDatabaseValue(list));
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(4, name);
        }
 
        String sn = entity.getSn();
        if (sn != null) {
            stmt.bindString(5, sn);
        }
 
        List resourceIdList = entity.getResourceIdList();
        if (resourceIdList != null) {
            stmt.bindString(6, resourceIdListConverter.convertToDatabaseValue(resourceIdList));
        }
        stmt.bindLong(7, entity.getStandardOrNot() ? 1L: 0L);
 
        List productCategoryNameList = entity.getProductCategoryNameList();
        if (productCategoryNameList != null) {
            stmt.bindString(8, productCategoryNameListConverter.convertToDatabaseValue(productCategoryNameList));
        }
 
        String exampleImgUrl = entity.getExampleImgUrl();
        if (exampleImgUrl != null) {
            stmt.bindString(9, exampleImgUrl);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(10, description);
        }
 
        String technicsSn = entity.getTechnicsSn();
        if (technicsSn != null) {
            stmt.bindString(11, technicsSn);
        }
 
        String serviceBaseSn = entity.getServiceBaseSn();
        if (serviceBaseSn != null) {
            stmt.bindString(12, serviceBaseSn);
        }
        stmt.bindLong(13, entity.getNeedPhoto() ? 1L: 0L);
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public SiveProBean readEntity(Cursor cursor, int offset) {
        SiveProBean entity = new SiveProBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // index
            cursor.isNull(offset + 2) ? null : listConverter.convertToEntityProperty(cursor.getString(offset + 2)), // list
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // sn
            cursor.isNull(offset + 5) ? null : resourceIdListConverter.convertToEntityProperty(cursor.getString(offset + 5)), // resourceIdList
            cursor.getShort(offset + 6) != 0, // standardOrNot
            cursor.isNull(offset + 7) ? null : productCategoryNameListConverter.convertToEntityProperty(cursor.getString(offset + 7)), // productCategoryNameList
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // exampleImgUrl
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // description
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // technicsSn
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // serviceBaseSn
            cursor.getShort(offset + 12) != 0 // needPhoto
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SiveProBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setIndex(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setList(cursor.isNull(offset + 2) ? null : listConverter.convertToEntityProperty(cursor.getString(offset + 2)));
        entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setSn(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setResourceIdList(cursor.isNull(offset + 5) ? null : resourceIdListConverter.convertToEntityProperty(cursor.getString(offset + 5)));
        entity.setStandardOrNot(cursor.getShort(offset + 6) != 0);
        entity.setProductCategoryNameList(cursor.isNull(offset + 7) ? null : productCategoryNameListConverter.convertToEntityProperty(cursor.getString(offset + 7)));
        entity.setExampleImgUrl(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setDescription(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setTechnicsSn(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setServiceBaseSn(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setNeedPhoto(cursor.getShort(offset + 12) != 0);
     }
    
    @Override
    protected final Long updateKeyAfterInsert(SiveProBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(SiveProBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(SiveProBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
